ShadingΒΆ

The particles can be shaded like any other object in Guerilla, but you can also create complex particle effects using the particle attributes. We'll show some simple exemples here.

Using the default shaders

The particles can be shaded with the standard shaders, Library/Materials/Surface, Library/Materials/Curves, Library/Materials/Particle, or Library/Materials/Volume regarding their mode.

The same particles rendered with different shaders : Point with the Particle shader, spheres with the Surface shader, a blobby with the Surface shader (using sss), multi-points with a Volume shader

Here is a summary of the particle mode and shader compatibility :

Particle Mode Particle Shader Surface Shader Volume Shader Curve Shader SSS Support
Sphere Yes Yes Yes No No
Streaks Yes No No Yes No
Sphere Yes Yes Yes No No
Blobby Yes Yes Yes No Yes
Sprites Yes Yes No No Yes

Use the particle attributes to control color

You can read directly the attributes stored in each particle by adding a PrimAttr shader.

In this case, we use the common color attribute "Cd" (Color diffuse) to control the color of particle colors.

Use the particle Age to control the opacity

First, in the RenderGraph, add a Particle shader node and an Attributes node to affect the particle system. In the attribute node, activate the Shading -> Opacity Mode to Vertex to get a fast opacity rendering. See User Guide/Shading/Opacity for details.

Then, select the Particle node and drag'n drop the Opacity shader input in a viewport. This action creates a sub-shader network that overrides the Opacity shader input.

In this sub-shader, create a Maya Particle -> Age Normalized node. Todo do that, open the node picker Ctrl+Space and type "Age" or use to the library.

Add an Invert node and build this network.

In the Particle node, activate the sub-shader for the Shadow Opacity input, and select the sub-shader we just built to re-use it in the Shadow Opacity shader input. Here it is RenderGraph|Particle|Opacity.

The result without and with the effect.

Using Maya Particles, you can also compute the opacity in the per particle alpha channel and use Opacity -> Use Particle Opacity. The result is the same. Use the particle Id to select a color in a gradient

Use the same technique as above but override now the Color -> Color shader input with this network. We use here a Randomized Ids node and a Texture -> Gradient node.

Here is the gradient we use, three constant colors.

The result without and with the effect.

Use the particle Speed to modulate the particle color

Use the same technique as above but override now the Color -> Intensity shader input with this network. We use here a Maya Particle -> Velocity node, a Length node and a Multiply node.

The result without and with the effect.

Write SL shaders for the particles

The particle attributes can also be accessed by the SL Box, to write more complex effects.

Here is a summary of the SL parameters available to the shader for each particle mode :

Particle Mode st (texture coordinates) v (curve parameter) N (normal) float12 (particle id)
Sphere No No Yes Yes
Streaks No Yes No Yes
Sphere No No Yes Yes
Blobby No No Yes No
Sprites Yes No Yes Yes

Here is a summary of the SL parameter to use to access the Maya Particle attributes exported with the Guerilla plug-in :

Attributes SL parameter Comments
Acceleration color3
Age float12
Age Normalized float12/float13 Computed with Age and Lifespan
CollisionNormalcolor6
CollisionTime float18
CollisionUV st4
Emission color4
Force color5
Ids float12
Randomized Ids float12*0.61803398874989-floor(float12*0.61803398874989) Computed with Ids
Lifespan float13
Mass float14
Opacity alpha
ParentUV st3
Radius float11
RGB Cs Color in Guerilla
SpriteScale st2
SpriteTwist float16
Velocity color2